package com.ly.mpayment.persist.service.provincialinformation;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.ly.mpayment.persist.entity.ProvincialInformation;
import com.ly.mpayment.persist.hibernate.Page;
import com.ly.mpayment.persist.service.AbstractService;

@Service
public class ProvincialInformationServiceImpl extends AbstractService<ProvincialInformation, Serializable> implements IProvincialInformationService{

	@Override
	public ProvincialInformation findById(String id) {
		return this.findUnique("select p from ProvincialInformation p where p.provinceuuid = ?", id);
	}

	@Override
	public boolean addProvincialinformation(ProvincialInformation pro) {
		if(pro != null){
			this.saveOrUpdate(pro);
			return true;
		}
		return false;
	}

	@Override
	public boolean updateProvincialinformation(ProvincialInformation pro) {
		if(pro != null){
			this.saveOrUpdate(pro);
			return true;
		}
		return false;
	}

	@Override
	public Page<ProvincialInformation> findPageProvincialinformation(Map<String, Object> parameters, int start,
			int pageSize) {
		return this.findPageByNamed("select p from ProvincialInformation p where 1 = 1 #[ and p.provincecode = :provincecode ]# #[ and p.provincename = :provincename ]# order by p.provincename", parameters, start, pageSize);
	}

	@Override
	public List<ProvincialInformation> findAllPro() {
		return this.find("select p from ProvincialInformation p where p.provincestatus = 1  order by p.provincename");
	}

	@Override
	public ProvincialInformation findByProvincename(String provincename) {
		return this.findUnique("select p from ProvincialInformation p where p.provincestatus = 1  and p.provincename = ?", provincename);
	}

}
